package leo.weixin.util;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.Random;

public class FileUtil {
    public static File multipartFileToFile(MultipartFile mFile){
        String filename = mFile.getOriginalFilename();
        String suffix = filename.substring(filename.lastIndexOf('.'));
        File file = null;
        try {
            file = File.createTempFile(System.currentTimeMillis()+"", suffix);
            mFile.transferTo(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return file;
    }
}
